#include "Model/OneOccurenceRule.hpp"
#include <cassert>

namespace Model
{

OneOccurenceRule::OneOccurenceRule()
	: period_( boost::posix_time::ptime(), boost::posix_time::ptime())
{

}

// ---------------------------------------------------------------------------------------------------------------------

OneOccurenceRule::OneOccurenceRule( const Calendar::Time& start, const Calendar::Time& end )
	: period_( start, end)
{
}

// ---------------------------------------------------------------------------------------------------------------------

void OneOccurenceRule::getPeriods( const Calendar::Time& start, const Calendar::Time& end, Calendar::PeriodSet& out )
{
	assert( out.empty());
	Calendar::PeriodSet results;
	results.merge( period_);
	results.intersect( start, end);

	out.swap( results);
}

} // namespace Model
